package com.summer.LanQiao;

import javax.rmi.CORBA.Util;
import java.util.Random;

//位运算
public class _01 {
    public static void main(String[] args) {
        //判断奇偶数
        int x = 100;
        //如果x&1结果为0为偶否者为奇
        //交换两个数可以两次异或运算
        int y = 200;
        x = x ^ y;
        y = y ^ x;
        x = x ^ y;
        System.out.printf("x=%d,y=%d\n",x,y);
        //消掉相同数
        int N = 11;
        int []arr = new int[N];
        for (int i = 0; i <arr.length-1 ; i++) {
            arr[i] = i+1;
        }
        //最后一个数是随机数
        int ran = new Random().nextInt(N-1)+1;
        arr[arr.length-1] = ran;
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(arr[i]);
        }
        int x1 = 0;
        for (int i = 1; i <=N-1 ; i++) {
            x1 = x1 ^ i;
        }
        for (int i = 0; i <N ; i++) {
            x1 = x1 ^ arr[i];
        }
        System.out.println("\n"+x1);
    }



}
